C = {
	BlockSize: 128,
	CanvasName: "GameCanvas"
};
window.createBackground = function () {
	let Background = new cc.Sprite(R.Background);
	ResizeTo(Background, C.GameWidth, C.GameHeight);
	Background.setAnchorPoint(0, 0);
	Background.setPosition(0, 0);
	Background.onResize = function () {
		ResizeTo(this, C.GameWidth, C.GameHeight);
		this.setPosition(0, 0);
	};
	return Background;
};
ResizeTo = function (sp, nw, nh) {
	sp.setScale(nw / sp._getWidth(), nh / sp._getHeight());
};

function GetUrlArgument(name) {
	let r = window.location.search.substr(1).match(new RegExp("(^|&)" + name + "=([^&]*)(&|$)"));
	return (r ? unescape(r[2]) : null);
}

CookieHelper = {
	set: function (key, value) {
		document.cookie = key + "=" + value;
	},
	get: function (key, def) {
		if (document.cookie.length === 0) return def;
		let st = document.cookie.indexOf(key + "=");
		if (st === -1) return def;
		st += key.length + 1;
		let en = document.cookie.indexOf(";", st);
		if (en === -1) en = document.cookie.length;
		return document.cookie.substring(st, en);
	},
	remove: function (key) {
		let exp = new Date();
		exp.setTime(exp.getTime() - 1);
		let cookie = CookieHelper.get(key, null);
		if (cookie) document.cookie = key + "=" + cookie + "; expires=" + exp.toGMTString();
	}
};